{extend name="public/base" /}
{block name="title"}站长设置{/block}
{block name="css"}
<link href="__PUBLIC__/static/inspinia/css/plugins/switchery/switchery.css" rel="stylesheet">
{/block}

{block name="main"}
<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-lg-12">
            <div class="tabs-container">
                <ul class="nav nav-tabs">                    
                    <li class="active"><a href="#tab-setting" aria-expanded="true" data-toggle="tab">百度站长配置</a></li>
                    <li class=""><a href="#tab-push-urls" aria-expanded="true" data-toggle="tab">推送urls</a>
                    <li class=""><a href="#tab-sitemap" aria-expanded="true" data-toggle="tab">站点地图</a></li>
                </ul>
                <div class="tab-content">
                    <div id="tab-setting" class="tab-pane active">
                        <div class="panel-body">

                            <div class="col-12">

                                <form class="form-horizontal ajax-form" action="{:url('Webmaster/baidu?tab=setting')}" method="post">
                                    
                                    <div class="form-group">
                                        <label class="col-lg-2 col-md-3 control-label">站长域名</label>
                                        <div class="col-lg-6 col-md-9">
                                            <input type="text" name="zhanzhang_site" placeholder="" class="form-control" autocomplete="off" value="{if empty(get_config('zhanzhang_site'))}{:get_config('protocol')}{:get_config('domain_name')}{else/}{:get_config('zhanzhang_site')}{/if}">
                                            <span class="help-block m-b-none">百度搜索资源平台：https://ziyuan.baidu.com/ 获取配置</span>
                                        </div>
                                    </div>                                    

                                    <div class="form-group">
                                        <label class="col-lg-2 col-md-3 control-label">站长token</label>
                                        <div class="col-lg-6 col-md-9">
                                            <input type="text" name="zhanzhang_token" placeholder="" class="form-control" autocomplete="off" value="{:get_config('zhanzhang_token')}">
                                            <span class="help-block m-b-none">百度搜索资源平台：https://ziyuan.baidu.com/ 获取配置</span>
                                        </div>
                                    </div> 
                                    
                                    <div class="form-group">
                                        <div class="col-lg-offset-2 col-lg-10">
                                            <button class="btn btn-success" type="submit">提交</button>
                                        </div>
                                    </div>
                                    
                                </form>

                            </div>

                        </div>
                    </div>

                    <div id="tab-push-urls" class="tab-pane">
                        <div class="panel-body">

                            <div class="col-12">

                                <form class="form-horizontal ajax-form" action="{:url('Webmaster/baidu?tab=push-urls')}" method="post">
                                    
                                    <div class="form-group">
                                        <label class="col-lg-2 col-md-3 control-label">推送urls</label>
                                        <div class="col-lg-6 col-md-9">
                                            <textarea class="form-control" name="urls" rows="10" placeholder=""></textarea>
                                            <span class="help-block m-b-none">每行一个url, 最多500个</span>
                                        </div>
                                    </div>
                                    
                                    <div class="form-group">
                                        <div class="col-lg-offset-2 col-lg-10">
                                            <button class="btn btn-success" type="submit">提交</button>
                                        </div>
                                    </div>
                                    
                                </form>

                            </div>

                        </div>
                    </div>

                    <div id="tab-sitemap" class="tab-pane">
                        <div class="panel-body">

                            <div class="col-12">

                                <form class="form-horizontal ajax-form" action="{:url('Webmaster/sitemap')}" method="post">
                                    
                                    <div class="form-group">
                                        <label class="col-lg-2 col-md-3 control-label">每页url数量(<50000)</label>
                                        <div class="col-lg-6 col-md-9">
                                            <input type="text" name="pageSize" placeholder="" class="form-control" autocomplete="off" value="800">
                                            <span class="help-block m-b-none">默认是800</span>
                                        </div>
                                    </div>                                    

                                    <div class="form-group">
                                        <label class="col-lg-2 col-md-3 control-label">sitemap文件最多个数</label>
                                        <div class="col-lg-6 col-md-9">
                                            <input type="text" name="maxPage" placeholder="" class="form-control" autocomplete="off" value="100">
                                            <span class="help-block m-b-none">访问地址：{:get_config('protocol')}{:get_config('domain_name')}/sitemap.xml, 提交百度是为 {domain}/sitemap-{1...n}.xml </span>
                                        </div>
                                    </div> 
                                    
                                    <div class="form-group">
                                        <div class="col-lg-offset-2 col-lg-10">
                                            <button class="btn btn-success" type="submit">生成站点地图</button>
                                        </div>
                                    </div>
                                    
                                </form>

                            </div>

                        </div>
                    </div>
                </div>

            </div>
        </div>
    </div>
</div>
{/block}

{block name="js"}
<!-- Switchery -->
<script src="__PUBLIC__/static/inspinia/js/plugins/switchery/switchery.js"></script>
<script>
  function changeConfig(name, value) {
      var url = "{:url(request()->controller() . '/index')}" + "?" + name + "=" + value;

      $.get(url, function(data) {
          if (data.code) {
              layer.msg(data.msg);
          } else {
              layer.msg(data.msg, function(){});
          }
      });
  }

  $(document).ready(function() {
      var elems = document.querySelectorAll('.ajax-switch');
      for (var i = 0; i < elems.length; i++) {
          var checkbox = elems[i];
          var switchery = new Switchery(checkbox, { color: '#1AB394' });
          checkbox.onchange = function() {
              changeConfig(this.name, this.checked);
          }
      }
  })

</script>

{/block}